﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ForkCarRelationManager.db;
using ForkCarRelationManager.DB;
using System.Data;
namespace ForkCarRelationManager
{
    public partial class RTform : Form
    {
        private int maintentype;
        
        private int maintenID;
        dbOperate dbo = new dbOperate();
        public RTform()
        {
            InitializeComponent();
        }
        public RTform(int maintentype,int maintenID)
        {
            this.maintentype = maintentype;
            this.maintenID = maintenID;
            InitializeComponent();
        }
        private void RTform_Load(object sender, EventArgs e)
        {
            string username = LoginInfo.CurrentUser.AccountName;
            int maintaintime = 0;
            int maintentime = 0;
            string sql = "select MaintainTime,MaintenTime from Admin where UserName='" + username + "'";
            DataTable admin = dbo.GetDate(sql);
            if (admin.Rows.Count!=0)
            {
                maintaintime =Convert.ToInt32( admin.Rows[0]["MaintainTime"].ToString());
                maintentime = Convert.ToInt32(admin.Rows[0]["MaintenTime"].ToString());
            }
            if (maintentype == 0)//维修
            {
                dayUD.Value = maintentime;
            }
            else
                dayUD.Value = maintaintime;

        }

        private void buttonX1_Click(object sender, EventArgs e)
        {
            string remindcontext = Remindtext.Text.Trim();
            int pushday = Convert.ToInt32(dayUD.Value);
            string datetime = DateTime.Now.AddDays(pushday).ToString("yyyy/M/d");
            string sql = " insert into RemindInfor (RemindTime,MaintenId,RemindContext,Ifhandle) values (#" + datetime + "#," + maintenID + ",'" + remindcontext + "',0)";
            if (dbo.UpdateAndInsert(sql))
            {
                DialogResult dr = MessageBox.Show("设置成功", "提示", MessageBoxButtons.OK);
                if (dr == DialogResult.OK)
                {

                    this.Close();
                }
            }

        }
    }
}
